#ifndef _PERIPHERAL_H_
#define	_PERIPHERAL_H_

#include "mytype.h"
#include "stdint.h"

#ifdef   _PERIPHERAL_MODULE_
#define  PERI_EXT
#else
#define  PERI_EXT  extern
#endif    


#define ADC_BUFFER_SIZE            8

#define ADC_CH_TEMP                0
#define ADC_CH_SIG1                1
#define ADC_CH_SIG2                2
#define ADC_CH_TEMP2               3
#define ADC_CH_SIG3                4
#define ADC_CH_SIG4                5
#define ADC_CH_SIG5                6
#define ADC_CH_AIRTEMP             7

#define ADC_CH_HUMI                ADC_CH_SIG1
#define ADC_CH_CO2                 ADC_CH_SIG2

typedef struct {
    uint32_t AdcSum[ADC_BUFFER_SIZE];
    uint16_t AdcResault[ADC_BUFFER_SIZE];
    uint16_t AdcResaultList[ADC_BUFFER_SIZE][16];
    uint16_t AdcResaultIndex;
    uint8_t AdcEnd;
    uint16_t AdcCnt;
    uint8_t isr_timeout_cnt;
    uint8_t tune_st;
} adc_res_type;

    PERI_EXT  adc_res_type adc_res;

    void adc_inserted_init(char pos);
    void adc_inserted_handle(void);
    
#undef PERI_EXT

#endif	/* _PERIPHERAL_H_ */

